package com.bringway.p2p.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bringway.framework.excel.ExcelSheet;
import com.bringway.global.dao.SysAttechmentDao;
import com.bringway.p2p.dao.POStzrDao;
import com.bringway.p2p.service.POStzrService;
/**
 * 
 * @author hc
 * @version 创建时间：2016年2月2日 上午9:50:22
 * @功能：POS单信息
 */

@Service
@Transactional
public class POStzrServiceImpl  implements POStzrService{
	
	
	

	@Autowired
	private POStzrDao postzrDao;
	@Autowired
	private SysAttechmentDao sysAttechmentDao;
	
	@Override
	public List queryPostzrList(JSONObject params) {
		// TODO Auto-generated method stub
		return postzrDao.queryPostzrList(params);
	}

	@Override
	public int getPostzrCount(JSONObject params) {
		// TODO Auto-generated method stub
		return postzrDao.getPostzrCount(params);
	}

	@Override
	public List<ExcelSheet> exportPosData(List<Map<String, Object>> czList) {
		 // 生成导入到EXECL的LIST
		List<ExcelSheet> sheetList = new ArrayList<ExcelSheet>();
		int headerCount = 1;
		// 点击汇总导出
		List<String[]> bodyList = new ArrayList<String[]>();
		for (int i = 0; i < czList.size(); i++) {
			String[] contents = new String[23];
			JSONObject obj = new JSONObject();
			obj = JSONObject.fromObject(czList.get(i));
			contents[0] = (i + 1)+"";//序号
			contents[1] = obj.optString("POS_ID");
			contents[2] = obj.optString("POS_CODE");
			contents[3] = obj.optString("USERID");
			contents[4] = obj.optString("ZQ_ID");
			contents[5] = obj.optString("TZJE");
			contents[6] = obj.optString("TZSJ");
			contents[7] = obj.optString("SH_USER_ID");
			contents[8] = obj.optString("SH_DATE");
			contents[9] = obj.optString("SH_CONTENT");
			contents[10] = obj.optString("SH_STATE");
			contents[11] = obj.optString("OPER_USER_ID");
			contents[12] = obj.optString("POS_BIZ_GYH");
			contents[13] = obj.optString("POS_OWNER_USER_ID");
			contents[14] = obj.optString("SJHM");
			contents[15] = obj.optString("TJR");
			contents[16] = obj.optString("POS_PLATFORM");
			contents[17] = obj.optString("POS_CUSTOMER_SEX");
			contents[18] = obj.optString("POS_CUSTOMER_SFZ");
			contents[19] = obj.optString("POS_CUSTOMER_HK_YHMC");
			contents[20] = obj.optString("POS_CUSTOMER_HK_CARD_NUM");
			contents[21] = obj.optString("POS_CUSTOMER_LY");
			contents[22] = obj.optString("JXRQ");
			bodyList.add(contents);
		}
		ExcelSheet excelSheet = new ExcelSheet();
		excelSheet.setBodyList(bodyList);
		excelSheet.setSheetName("service层实现导出Excel");
		excelSheet.setFromRow(headerCount);
		sheetList.add(excelSheet);
		return sheetList;
	}
}
